<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>前台登录</title>
    <!--必要样式-->
    <link href="/static/common/js/layui/css/layui.css" th:href="@{/common/js/layui/css/layui.css}" rel="stylesheet" media="all" />
    <link href="/static/common/css/index/loginIndex.css" th:href="@{/common/css/index/loginIndex.css}" rel="stylesheet" type="text/css" />
    <link href="/static/common/css/common.css" th:href="@{/common/css/common.css}" rel="stylesheet" type="text/css" media="all" />
    <link rel="stylesheet" href="/static/common/css/font_1514218_0qs2i8pjuvs/iconfont.css" th:href="@{/common/css/font_1514218_0qs2i8pjuvs/iconfont.css}" media="all"/>
    <script>
        var ctx = '[[@{/}]]';
    </script>
</head>
<body>
<div id="loginIndex">
    <div class="loginIndex">
            <div class="login-main">
                <header class="layui-elip">欢迎登录</header>
                <form class="layui-form" style="width: 100%;height: 280px;padding: 39px 30px 0;box-shadow:#ff5722 0px 20px 50px;">
                    <div class="layui-input-inline">
                        <i class="layui-icon layui-icon-username" style="font-size: 30px; color: lightgray;"></i>
                        <input type="text" name="userName" required lay-verify="required" placeholder="请输入用户名" autocomplete="off"
                               class="layui-input">
                    </div>
                    <div class="layui-input-inline">
                        <i class="layui-icon layui-icon-password" style="font-size: 30px; color: lightgray;"></i>
                        <input type="password" name="password" required lay-verify="required" placeholder="请输入用户名密码" autocomplete="off"
                               class="layui-input">
                    </div>
                    <div class="layui-input-inline login-btn">
                        <button lay-submit lay-filter="login" class="layui-btn layui-btn-normal">登录</button>
                    </div>
                    <!--<hr>-->
                    <svg class="icon">
                        <use xlink:href="#iconweixin"></use>
                    </svg>
                    <svg class="icon">
                        <use xlink:href="#iconQQ"></use>
                    </svg>
                    <svg class="icon">
                        <use xlink:href="#iconweibo1"></use>
                    </svg>
                    <!--<div class="layui-input-inline">-->
                        <!--<button type="button" class="layui-btn layui-btn-primary">QQ登录</button>-->
                    <!--</div>-->
                    <!--<div class="layui-input-inline">-->
                        <!--<button type="button" class="layui-btn layui-btn-normal">微信登录</button>-->
                    <!--</div>-->
                    <p><a href="registerIndex.html" class="fl">立即注册</a><a href="javascript:;" class="fr">忘记密码？</a></p>
                </form>
        </div>
    </div>
</div>
</body>
<script src="../../../static/common/css/font_1514218_0qs2i8pjuvs/iconfont.js" th:src="@{/common/css/font_1514218_0qs2i8pjuvs/iconfont.js}"></script>
<script src="../../static/common/js/layui/layui.js" th:src="@{/common/js/layui/layui.js}"></script>
<script src="../../static/common/js/jquery/jquery.min.js" th:src="@{/common/js/jquery/jquery.min.js}"></script>
<script src="../../static/common/js/vue/vue.js" th:src="@{/common/js/vue/vue.js}"></script>
<script src="../../static/common/js/element-2/element.js" th:src="@{/common/js/element-2/element.js}"></script>
<script src="../../static/index/js/loginIndex.js" th:src="@{/index/js/loginIndex.js}"></script>
<script type="text/javascript">
    layui.use(['form','layer','jquery'], function () {
        // 操作对象
        var form = layui.form;
        var $ = layui.jquery;
        form.on('submit(login)',function (data) {
            // console.log(data.field);
            $.ajax({
                url:'/zzh/zc/login.do',
                data:data.field,
                dataType:'json',
                type:'post',
                success:function (data) {
                    debugger;
                    console.log(data);
                    if (data.success){
                        sessionStorage.setItem("user",data.content.user.userName);
                        sessionStorage.setItem("tokenHead",data.content.tokenHead);
                        sessionStorage.setItem("token",data.content.token);
                        layer.msg('登录成功!',{
                            icon:1,
                            time:1000
                        }, function(){
                            setTimeout(function () {
                                window.location.href = "toIndex.html";
                            },500)
                        });
                    }else{
                        layer.msg('登录名或密码错误',{
                            icon:2,
                            time:1000
                        });
                    }
                }
            })
            return false;
        })

    });
</script>
</html>